package com.ruoyi.fetv.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.fetv.controller.vo.Label;
import com.ruoyi.fetv.controller.vo.school.AddReq;
import com.ruoyi.fetv.controller.vo.school.EditReq;
import com.ruoyi.fetv.domain.FetvSchool;
import com.ruoyi.fetv.mapper.FetvSchoolMapper;
import com.ruoyi.fetv.service.IFetvSchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 高校Service业务层处理
 *
 * @author Jack
 * @date 2023-03-07
 */
@Service
public class FetvSchoolServiceImpl implements IFetvSchoolService {
    @Autowired
    private FetvSchoolMapper fetvSchoolMapper;

    /**
     * 查询高校
     *
     * @param id 高校主键
     * @return 高校
     */
    @Override
    public FetvSchool selectFetvSchoolById(Long id) {
        return fetvSchoolMapper.selectFetvSchoolById(id);
    }

    /**
     * 查询高校列表
     *
     * @param fetvSchool 高校
     * @return 高校
     */
    @Override
    public List<FetvSchool> selectFetvSchoolList(FetvSchool fetvSchool) {
        return fetvSchoolMapper.selectFetvSchoolList(fetvSchool);
    }

    /**
     * 新增高校
     *
     * @param fetvSchool 高校
     * @return 结果
     */
    @Override
    public int insertFetvSchool(AddReq fetvSchool) {
        fetvSchool.setCreateTime(DateUtils.getNowDate());
        return fetvSchoolMapper.insertFetvSchool(fetvSchool);
    }

    /**
     * 修改高校
     *
     * @param fetvSchool 高校
     * @return 结果
     */
    @Override
    public int updateFetvSchool(EditReq fetvSchool) {
        fetvSchool.setUpdateTime(DateUtils.getNowDate());
        return fetvSchoolMapper.updateFetvSchool(fetvSchool);
    }

    /**
     * 批量删除高校
     *
     * @param ids 需要删除的高校主键
     * @return 结果
     */
    @Override
    public int deleteFetvSchoolByIds(Long[] ids) {
        return fetvSchoolMapper.deleteFetvSchoolByIds(ids);
    }

    @Override
    public String getNameById(String id) {
        return fetvSchoolMapper.getSchoolNameById(id);
    }

    @Override
    public List<Label> getIdAndNameByName(String name) {

        return fetvSchoolMapper.getIdAndNameByName(name);


    }

    /**
     * 删除高校信息
     *
     * @param id 高校主键
     * @return 结果
     */
    @Override
    public int deleteFetvSchoolById(Long id) {
        return fetvSchoolMapper.deleteFetvSchoolById(id);
    }
}
